package cn.consult.controller.sys.apartment;

import cn.consult.common.api.CommonResult;
import cn.consult.sys.entity.TERule;
import cn.consult.sys.service.TERuleService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ Author：周xx
 * @ Date：2024-04-13-11:37
 * @ Version：1.0
 * @ Description：电表规则
 */
@Api(tags = "公寓管理 > 电表规则")
@RestController
@RequestMapping("/apartment/eRule")
public class TERuleController {

    @Autowired
    TERuleService teRuleService;

    @ApiOperation("selectPage => 分页查询")
    @GetMapping("/selectPage")
    public CommonResult selectPage(@RequestParam Map<String, Object> params) {
        IPage<TERule> page = teRuleService.selectPage(params);
        return CommonResult.success(page);
    }

    @ApiOperation("saveRule => 添加规则")
    @PostMapping("/saveRule")
    public CommonResult saveRule(@RequestBody TERule teRule) throws Exception {
        boolean save = teRuleService.saveRule(teRule);
        return CommonResult.success(save);
    }

    @ApiOperation("updateRule => 修改规则")
    @PutMapping("/updateRule")
    public CommonResult updateRule(@RequestBody TERule teRule) throws Exception {
        boolean update = teRuleService.updateR(teRule);
        return CommonResult.success(update);
    }

    @ApiOperation("delRule => 删除规则")
    @DeleteMapping("/delRule/{id}")
    public CommonResult delRule(@PathVariable Long id) {
        boolean b = teRuleService.removeById(id);
        return CommonResult.success(b);
    }


}
